Repository navigation
process and fs; Array flat/flatMap/toSpliced, Map.groupBy, String.fromCodePoint - #90
Merged
Merged
Conversation
process (Node's, with functions for its properties): argv, getEnv, setEnv,
unsetEnv, env, cwd, chdir, pid, platform, exit.
fs, synchronous, by Node's names: existsSync, statSync, readFileSync,
readTextFileSync, writeFileSync, writeTextFileSync, appendFileSync,
appendTextFileSync, readdirSync, mkdirSync, rmSync, rmdirSync, renameSync,
copyFileSync. Errors carry Node's message ("ENOENT: ..., open 'a.txt'").
Both are namespaces in lib.generics.ts over a new wrapper, os.cpp, which every
build script now compiles. UTF-8 paths, the wide API on Windows. Tests:
process.ts, process_exit.ts, fs.ts; docs/process-fs.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J8KRfWzDJu2qyU3x7oX6kv
- __os_text: a u8 buffer ended with 0; a char can't take null in the generics' strict null mode, which failed every program. - The helpers take their type parameter from their argument, as sleep does. - process.env() gives [name, value] pairs: naming Map<string, string> above the Map class made that type before Map was declared, and every program's own Map<string, string> then had no members (map_get, map_set, ... failed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8KRfWzDJu2qyU3x7oX6kv
A bare array literal pushed onto [string, string][] was a string[], which can't be cast to the pair. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8KRfWzDJu2qyU3x7oX6kv
- T[]: flat() (one level), flatMap, toSpliced; Array<T>: flatMap, toSpliced. toSpliced shares one helper, __toSpliced, between the two. - Map.groupBy(items, keySelector): each group made whole before it goes in. Not under -mm=own, whose Map values can't be arrays (the test says so). - String.fromCodePoint, with fromCharCode's UTF-8 encoder moved out into utf8Push for both. Tests: array_flat.ts, map_groupBy.ts, string_fromCodePoint.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8KRfWzDJu2qyU3x7oX6kv
…ring keys array_flat: a literal [1, 2, 3] is an s32[], which a callback taking a number did not match. map_groupBy: keys from substring, not item[0], and each group printed, so a wrong one shows what it held. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8KRfWzDJu2qyU3x7oX6kv
This was referenced Nov 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
processandfsnamespaces tosrc/generics/lib.generics.ts, over a new native wrappersrc/wrappers/os.cpp, and a few missing Array, Map and String methods.processWorks like Node's
process, except that what Node has as properties are functions here, because a library namespace keeps no state set up at startup:argv(),getEnv(name)(undefinedwhen unset),setEnv,unsetEnv,env()([name, value]pairs),cwd(),chdir,pid(),platform(),exit(code).argvcomes from/proc/self/cmdlineon Linux/Android andGetCommandLineWon Windows. Under the JIT it starts with tslang and its options, then the script, likenode script.js.env()returns pairs, not aMap. WhenprocessnamedMap<string, string>above theMapclass, every program's ownMap<string, string>lost its members.fsSynchronous, with Node's names:
existsSync,statSync({ isFile, isDirectory, size, mtimeMs }),readFileSync(aUint8Array),readTextFileSync(a string),writeFileSync/writeTextFileSync,appendFileSync/appendTextFileSync,readdirSync(sorted),mkdirSync({ recursive }),rmSync({ recursive, force }),rmdirSync,renameSync,copyFileSync.Errorwith Node's message:ENOENT: no such file or directory, open 'a.txt'.Array, Map, String
T[]:flat()(one level only),flatMap,toSpliced.Array<T>:flatMap,toSpliced. BothtoSpliceds share one helper.Map.groupBy(items, keySelector): groups in the order their keys first come. It doesn't work under-mm=own, where Map values can't be arrays, so its test is marked// not own.String.fromCodePoint: a code point outside 0–0x10FFFF is aRangeError.fromCharCode's UTF-8 encoder moved into a helper that both use.Build, tests, docs
os.cppis added toscripts/build.sh,scripts/build_core.batandscripts/build_android.bat. It linksshell32on Windows via#pragma comment.process.ts,process_exit.ts,fs.ts,array_flat.ts,map_groupBy.ts,string_fromCodePoint.ts. The fs test works in__fs_test/, which is now in.gitignore.docs/process-fs.mdand README entries.Known limits
EFBIGerror, because lengths areint, as inStdio.mtimeMsis only accurate to the second on Windows.exit()flushes only this library's C runtime, so text fromprint()that hasn't been flushed yet may be lost.Array.isArray, because types are fixed at compile time.String.raw. It needs two compiler changes:TemplateStringsArrayisstring[]with no.raw.mlirGen(TaggedTemplateExpression)).codePointAtreturns one UTF-8 byte, not a code point. This was already the case before this PR.Testing
On
13ad237all four Ubuntu jobs (gc, rc, none, own) pass. The Windows jobs for that commit are still running.🤖 Generated with Claude Code
https://claude.ai/code/session_01J8KRfWzDJu2qyU3x7oX6kv